﻿using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    /// <summary>
    /// AOrganizationBO
    /// </summary>
    public sealed class AOrganizationBO
    {
        /// <summary>
        /// Prevents a default instance of the <see cref="AOrganizationBO"/> class from being created.
        /// </summary>
        private AOrganizationBO()
        {
        }

        /// <summary>
        /// Gets the organization list.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public static IQueryable<Organization> GetOrganizationList(AOrganizationFilter filter, string sortType, int startRowIndex, int maxRows)
        {
            return Dao.AOrganizationDao.GetListOrganization(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Updates the status.
        /// </summary>
        /// <param name="organizationId">The organization id.</param>
        /// <param name="active">if set to <c>true</c> [active].</param>
        /// <returns></returns>
        public static bool UpdateStatus(int organizationId, bool active)
        {
            return Dao.AOrganizationDao.UpdateStatus(organizationId, active);
        }

        /// <summary>
        /// Gets the list organization count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public static int GetListOrganizationCount(AOrganizationFilter filter)
        {
            return Dao.AOrganizationDao.GetListOrganizationCount(filter);
        }

        /// <summary>
        /// Gets the list organization id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static Organization GetListOrganizationId(int id)
        {
            return Dao.AOrganizationDao.GetOrganizationById(id);
        }
    }
}